<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <!-- 1. 搭建静态界面 -->
    <div id='app'>
        <input type="text" v-model="num1">
        <select v-model="operato">
            <option value="+">+</option>
            <option value="-">-</option>
            <option value="*">*</option>
            <option value="000">/</option>
        </select>
        <input type="text" v-model="num2">
        <input type="button" value="=" @click="calc">
        <span>{{result}}</span>
    </div>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                num1: '',
                num2: '',
                operato: '+',
                result: ''
            },
            methods: {
                calc() {
                    console.log(this.num1 + this.operato + this.num2);
                    this.result  = eval(this.num1 + this.operato + this.num2)
                    // console.log(this.num1);
                    // console.log(this.num2);
                    // console.log(this.operato);
                    // // 运算
                    // this.num1 = Number(this.num1)
                    // this.num2 = Number(this.num2)
                    // switch (this.operato) {
                    //     case '+':
                    //         this.result = this.num1 + this.num2
                    //         break
                    //     case '-':
                    //         this.result = this.num1 - this.num2
                    //         break
                    //     case '*':
                    //         this.result = this.num1 * this.num2
                    //         break
                    //     case '/':
                    //         this.result = this.num1 / this.num2
                    //         break
                    //     default:
                    //         alert("未知运算符")
                    // }
                }
            },
        })
    </script>
</body>

</html>